/**
 * 计算二次多项式的参数
 * y = a + bx + cx^2
 */
export function calPolynomialParameters(x0, y0, x1, y1, x2, y2) {

    const ans = [];
    const c = ( ( (x1 - x0) / (x2 - x0) ) * (y2 - y0) - (y1 - y0)) / ( (x1 - x0) * (x2 - x1) );
    const b = ( (y1 - y0) - c * (x1 * x1 - x0 * x0) ) / (x1 - x0);
    const a = y0 - b * x0  - c * x0 * x0;
    console.info("recal a is " + a + " b is " + b + " c is " + c);
    ans.push(a);
    ans.push(b);
    ans.push(c);
    return ans;

}

/**
 * 计算二次多项式的结果
 * @param x  x
 * @param a 参数 a
 * @param b 参数 b
 * @param c 参数 c
 * @returns {*}
 */
export function calPolynomialResult(x, a, b, c) {
    return a + b * x + c * x * x;
}


